package enumdemo;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test {
    //反射获取不了枚举对象
    public static void main(String[] args) {
        Class<?> c = null;
        try{
            c = Class.forName("enumdemo.TestEnum");
            Constructor<?> constructor = c.getDeclaredConstructor(String.class,int.class,
                    String.class,int.class);
            constructor.setAccessible(true);
            constructor.newInstance("棕色",6);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
